package com.tianzeculture.stagebao.activity.personal;

import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.tianzeculture.stagebao.R;
import com.tianzeculture.stagebao.base.BaseActivity;
import com.tianzeculture.stagebao.net.CommonRestUsage;
import com.tianzeculture.stagebao.network.Request;
import com.tianzeculture.stagebao.network.enity.MSG;
import com.tianzeculture.stagebao.network.util.ToastUtil;
import com.tianzeculture.stagebao.util.StatusBarUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/6/25 0025.
 * 意见反馈
 */

public class SuggestionActivity extends BaseActivity {
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.edtSuggestion)
    EditText edtSuggestion;
    @BindView(R.id.btnSuggestion)
    Button btnSuggestion;

    @Request
    CommonRestUsage commonRestUsage = null;
    private int comment = 101;

    @Override
    public void initUI() {
        super.initUI();
        StatusBarUtil.setWindowStatusBarColor(this, R.color.colorGray_F8);
        tvTitle.setText("意见反馈");
    }

    @OnClick(R.id.btnSuggestion)
    public void saveSuggestion() {
        if ("".equals(edtSuggestion.getText().toString().trim())) {
            ToastUtil.showShort(this, "请输入您的反馈意见");
            return;
        }
        commonRestUsage.comment(comment, edtSuggestion.getText().toString().trim());
    }


    @Override
    public void refreshUI(int taskId, MSG msg) {
        super.refreshUI(taskId, msg);
        if (taskId == comment) {
            ToastUtil.showShort(this, msg.getMessage());
            if (msg.getData())
                finish();
        }
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_suggestion;
    }
}
